package org.fioma.tree.suffixTree.memory;

import org.fioma.tree.LabelFactory;
import org.fioma.tree.NodeFactory;
import org.fioma.tree.bytes.LabelRefBytes;

public class FinalNodeFactoryMemory extends SuffixNodeFactoryMemoryBytes<FinalInternalSuffixNodeMemory, FinalLeafSuffixNodeMemory> implements
		NodeFactory<LabelRefBytes, FinalInternalSuffixNodeMemory, FinalLeafSuffixNodeMemory> {

	public FinalNodeFactoryMemory(long nodesSize, int labelSize, LabelFactory<LabelRefBytes> labelFactory) {
		super(nodesSize, labelSize, labelFactory);
	}

	@Override
	public FinalInternalSuffixNodeMemory createInternalNode(FinalInternalSuffixNodeMemory parent, LabelRefBytes label) {
		long pos = this.allocMemoryInternalNode();
		FinalInternalSuffixNodeMemory ret = new FinalInternalSuffixNodeMemory(this, pos);
		ret.setLabel(label);
		ret.setParent(parent);
		return ret;
	}

	@Override
	public FinalLeafSuffixNodeMemory createLeafNode(FinalInternalSuffixNodeMemory parent, LabelRefBytes label) {
		long pos = this.allocMemoryLeafNode();
		FinalLeafSuffixNodeMemory ret = new FinalLeafSuffixNodeMemory(this, pos);
		ret.setLabel(label);
		ret.setParent(parent);
		return ret;
	}

	@Override
	public FinalInternalSuffixNodeMemory createNewRootNode() {
		long pos = this.allocMemoryInternalNode();
		FinalInternalSuffixNodeMemory ret = new FinalSuffixRootMemory(this, pos);
		return ret;
	}

}
